//
//  String+Category.swift
//  SinaWebo
//
//  Created by mis on 16/3/21.
//  Copyright © 2016年 mis. All rights reserved.
//

import Foundation

extension String {
    func linhref() -> (link: String?, clienName: String?) {
        let pattern = "<a href=\"(.*?)\".*?>(.*?)</a>"
        let regx = try! NSRegularExpression(pattern: pattern, options: [])
        let result = regx.firstMatchInString(self, options: [], range: NSRange(location: 0, length: characters.count))
        let range2 = result?.rangeAtIndex(1)
        let range3 = result?.rangeAtIndex(2)
        var subStr2: String?
        var subStr3: String?
        if let r2 = range2, r3 = range3 {
            subStr2 = (self as NSString).substringWithRange(r2)
            subStr3 = (self as NSString).substringWithRange(r3)
        }
        return (subStr2, subStr3)
    }
}